﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Interface;

namespace Model
{
    public class FbmFeatureCollection // This class is written by Per Leth Andersen, Tien - may 8
    {
        public List<FbmFeature> FeatureCol { get; set; }

        public FbmFeatureCollection()
        {
            FeatureCol = new List<FbmFeature>();
        }

        #region Methods
        public FbmFeature Add(int id, IFbmReport ident, string name, string ctrl, double nominal, double tolpos, double tolneg)
        {
            FbmFeature _feature = new FbmFeature(id, ident, name, ctrl, nominal, tolpos, tolneg);
            FeatureCol.Add(_feature);
            return _feature;
        }
        public FbmFeature Find(int id) // Find one feature:
        {
            int max = FeatureCol.Count;
            int min = 0;
            while (max >= min)
            {
                int mid = (max + min) / 2;
                if (FeatureCol[mid].Id < id)
                    min = mid + 1;
                else if (FeatureCol[mid].Id > id)
                    max = mid - 1;
                else
                    return FeatureCol[mid];
            }
            return null;
        }
        #endregion
    }
}